
package com.wutianyi.myRegex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Hello world!
 * 
 */
public class MyRegex {
	
	private Pattern pattern;
	
	public MyRegex(String patternStr, boolean caseSensitive) {
		if(caseSensitive) {
			pattern = Pattern.compile(patternStr, Pattern.CASE_INSENSITIVE);
		} else {
			pattern = Pattern.compile(patternStr);
		}
	}
	
	
	
	public static void main(String[] args) {
		Pattern pattern = Pattern.compile("(wutian)");
		Matcher matcher = pattern.matcher("asfasfwutianasfaswutian");
//		while(matcher.find()) {
//			System.out.println(matcher.group());	
//		}
//		
//		matcher.find();
		int groupCount = matcher.groupCount();
		matcher.find();
		System.out.println(groupCount);
		for(int i = 0; i < groupCount; i ++) {
			
			System.out.println(matcher.group(i));
		}
	}
}
